package com.net.xpay.core.enums;

import com.net.common.enums.base.StringEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 转账单据状态。可能出现的状态如下：
 */
@Slf4j
@Getter
@AllArgsConstructor
public enum SafePayOrderStatus implements StringEnum<SafePayOrderStatus> {
    ABNORMAL("ABNORMAL", "异常"),
    DISUSE("DISUSE", "废弃"),
    WAIT_ENSURE("WAIT_ENSURE", "待转账"),
    WAIT_TRANS("WAIT_TRANS", "转账处理中"),

    SUCCESS("SUCCESS", "成功"),
    FAIL("FAIL", "失败"),
    REFUND("REFUND", "退票"),
    DEALING("DEALING", "处理中"),
    UNKNOWN("UNKNOWN", "未知")
    ;

    public static SafePayOrderStatus of(String status) {
        try {
            return SafePayOrderStatus.valueOf(status);
        } catch (Exception e) {
            log.error("of error|status={}", status);
            return UNKNOWN;
        }
    }

    private String value;

    private String desc;
}
